#include "CProcTextureMarble.h"
#include "CPerlinNoise.h"
#include <math.h>



CProcTextureMarble::CProcTextureMarble(float persistance, int octave):m_persistance(persistance),
								m_octave(octave){}


CColor CProcTextureMarble::getColor(const CVector3f& p)const
{
	CVector3f newP = m_transform * p;

	const CColor c2(0.7f, 0.7f, 0.7f, 1); // light gray
	const CColor c1 (1.0, 1.0, 1.0, 1); // white

	float perlin = CPerlinNoise::perlin(newP, m_persistance, m_octave);

    float f = 1 - sqrt(fabs(sin(2 * 3.141592f * perlin)));

	return c1 * (1 - f) + c2 * f;

}